<?php include './include/conf.php'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">

<head>
<title>Jardins familiaux de Lacroix-Falgarde : information</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="style/style.css" />
</head>

<body>	
	<div id="global">
		<!-- header -->
		<?php include './include/header.php' ; ?>
		
		<!-- fil d'ariane et espace adh?rent -->
		<p id="ariane">
			vous êtes ici : <a href="index.php">accueil</a> &gt; <a href="informations.php"> adhérent </a>
			<a id="espaceAdherent" href="connexion.php">espace adhérent</a>
		</p>	

		<!-- contenu -->
		<div id="contenu">
			<!-- menu gauche -->
			<?php include('./include/menu_gauche.php'); 
			if(!isset($_GET['idInfo'])){
				echo 'Erreur lors du chargement de la page';
			}
			else
			{
				$selectInfo =$pdo->prepare('select i.*,concat(a.prenom," ",a.nom) as auteur from information i,adherent a where i.auteur = a.id_adherent and i.id_information ='.$_GET['idInfo'].';');
				$selectInfo->execute();
					
				$info =  $selectInfo->fetch();
				$selectInfo->closeCursor();
			
				echo '		
				<div id="information">
				<h1>'.$info->titre.'</h1>
				<h2>Auteur : '.$info->auteur.'</h2>
				<h2>Date : '.$info->date.'</h2>
				
				'.$info->contenu.'
				
				<hr/>
				
				<h3>Commentaires :</h3>
				';
				
				$requete = $pdo->prepare("select c.*,concat(a.prenom,' ',a.nom) as auteur from commentaire c,adherent a where a.id_adherent = c.auteur and c.en_attente = 0 and c.id_information='".$_GET['idInfo']."'");
				$requete->execute(array());
				if ($requete->rowCount() == 0)
				{
					echo '(Aucun commentaire)';
				}
				
				while($comment = $requete->fetch())
				{
					echo '<div class="commentaire" >';
					echo '<div class="entete">';
					echo '<span class="nom"><strong>'.$comment->auteur.' :</strong>	</span>';
					echo '<span class="date">Posté le : '.$comment->date.' </span>';
					echo '</div>';
					echo '<p class="post">';
					echo $comment->contenu;
					echo '</p>';
					echo '</div><hr/></div>';
				}
				
				echo '
				<hr/>
				<form method="post" action="ajoutcommentaire.php">
				<p>
				<label for="com">Commentaire :</label><br />
				<textarea name="com" id="comment" rows="5" cols="78"></textarea>
				<input type="hidden" name="identifiant" value="'.$_SESSION['identifiant'].'">
				<input type="hidden" name="id_information" value="'.$_GET['idInfo'].'">
				<input type="submit" value="Proposer" />
				<button type="button">Annuler</button>
				</p>
				</form>';
			}
		?>
		</div> 

		<!-- footer -->
		<?php include('./include/footer.php'); ?>
	</div>
</body>
</html>